package com.jzo2o.orders.manager.controller.consumer;

import com.jzo2o.api.market.dto.response.AvailableCouponsResDTO;
import com.jzo2o.orders.manager.service.IOrdersCreateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "优惠券相关接口")
@RequestMapping("/consumer/orders")
public class CouponController {

    @Resource
    private IOrdersCreateService ordersCreateService;


    @GetMapping("getAvailableCoupons")
    @ApiOperation("获取可用优惠券")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "serveId", value = "购买的服务id", required = true, dataTypeClass = Long.class),
            @ApiImplicitParam(name = "purNum", value = "购买数量", required = false, dataTypeClass = Integer.class)
    })
    public List<AvailableCouponsResDTO> getAvailableCoupons(
            @RequestParam(value = "serveId", required = true) Long serveId,
              @RequestParam(value = "purNum",required = true) Integer purNum
    ){
        return ordersCreateService.getAvailableCoupons(serveId, purNum);
    }

}
